Repository navigation
feat(metadata): add systems grants, document and search sources, and duplicate-name checks - #712
Merged
Merged
Conversation
Adds ADR-0070 part 2 to metaobjects-systems-core in TypeScript, C#, Java/Kotlin, Python and Rust: - role grants: grant.rdb (@Schema, @access, @Maintain), grant.keyValue, .objectStore, .document, .search, .queue and .stream, each naming a resource of its own kind and its own system in @resource (ERR_GRANT_CROSSES_SYSTEM), and grant.api (@api, @operations, @credential). - @runsAs must name a role.service of the app's own system (ERR_RUNSAS_OTHER_SYSTEM). - source.rdb takes @resource; new source.document (@resource, @collection) and source.search (@resource, @index), registered by the systems provider rather than core. - Inside a system a name is used once per type: a second child of the same type and name but another subtype is ERR_DUPLICATE_NAME. A same-subtype redeclaration still merges. Nine conformance fixtures, including the ambiguous bare @heldBy name that PR 710 left untested. The TS and Python "targetSubTypes narrows" tests now assert ERR_REF_WRONG_KIND on holder. Regenerated: the registry manifest, the metamodel docs, the site reference and payload, the requirement harness, plus requirement entries for the new subtypes.
Python refused a system holding role.service api and an overlay role.user api with ERR_DUPLICATE_NAME, where every other port takes the overlay path and loads it. Skip the check when either node is an overlay, as Rust does. Pinned by the shared fixture systems-duplicate-name-overlay-in-system.
The providability check asked whether an entity has a read source by reading @kind off every source child. Use naming::source_is_read_only, which is rdb-only, as the other ports' isReadOnly is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
spec/metamodel/systems.jsonand every port:grant.rdb,grant.keyValue,grant.objectStore,grant.document,grant.search,grant.queue,grant.stream(each names a resource of its own kind in the same system, elseERR_GRANT_CROSSES_SYSTEMorERR_REF_WRONG_KIND), andgrant.api.@runsAsmust name a service role of the same system (ERR_RUNSAS_OTHER_SYSTEM).source.documentandsource.searchin the systems provider (backed by the sameMetaSourceclass), and adds an optional@resourceonsource.rdb. Writability,@roleand the one-primary rule apply tosource.rdbonly. Lifecycle, sourceless wire contract, payload-shape and column-collision checks also ignore non-rdb sources.ERR_PROJECTION_INHERITED_SOURCEand the value-object no-source rule still count any source.ERR_DUPLICATE_NAMEfor two children of one system node with the same type and name and different subtypes. Overlay nodes skip the check in every port, including Python and Rust. Adds shared conformance fixtures for grants, sources, each refusal and an ambiguous bare@heldByname, and regenerates the registry manifest, metamodel docs, site reference and requirement harness.Validation
Risk Assessment
Testing
Baseline command passed. Python: the overlay fixture loads clean and the same-type duplicate is still refused with ERR_DUPLICATE_NAME, both driven through the real Python loader adapter on fixtures (live, synthetic inputs). Python focused conformance tests pass (2522). Rust: full cargo test suite passes, which covers the derived-field providability change, but I did not drive a live Rust scenario for it, so it is untested. Overall: go on the Python change; Rust change verified by unit/conformance tests only.
Evidence: Python conformance loader results (overlay pass, duplicate refused)
Evidence: Loader check driver script
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/rust/metaobjects/src/validate/rules.rs:775- Lifecycle liveness is now rdb-only in all ports, but only TypeScript updated the ERR_TRANSITION_NOT_ON_ENTITY text. The others still say "An entity with no source at all may carry a lifecycle: it is inert until a source is added." That is now false: an entity with only a source.document or source.search is also inert, and adding one does not make the lifecycle live. Same text at server/csharp/MetaObjects/Loader/ValidationPasses.Rules.cs:231, server/java/metadata/src/main/java/com/metaobjects/loader/RulesValidation.java:259 and server/python/src/metaobjects/loader/validate_rules.py:327. Stale header comments: ValidationPasses.Rules.cs:18, validate_rules.py:20 and server/typescript/packages/metadata/src/loader/rules-validation.ts:18. Use the TypeScript wording ("no relational source ... until a source.rdb is added").docs/recipes/document-graph-and-wide-column-stores.md:135- Docs do not fully match the new source subtypes. (1) This recipe says "Core's systems provider" registers source.document and source.search, but they are deliberately not core. (2) Its closing paragraph still argues that registering a paradigm would make Order persistable to every tier, which is no longer true for the two registered ones. (3) Lines 20-21 and 33 still define a sourceless entity as having nosource.*child, while every port's predicate now means no source.rdb. Same invariant: docs/features/extending-with-providers.md:146 ("declare a source.* child" as how an entity gets a table), agent-context/skills/metaobjects-codegen/references/any-stack.md:25 ("the registered sources: only source.rdb", whilemeta typesnow also lists document and search) and .claude/rules/codegen-architecture.md:126 ("There is ONE subtype").✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainsscripts/ci-local.sh --affected --strict-toolchains (baseline, passed; not re-run)server/python: .venv/bin/python -m pytest -q tests -k 'conformance or systems or duplicate or overlay' -> 2522 passedserver/rust: cargo test -q --offline -> all suites oklive: PYTHONPATH=src:. .venv/bin/python tests/conformance/conformance_adapter.load_fixture on fixtures/conformance/systems-duplicate-name-overlay-in-system/input -> codes [] (loads clean)live: same loader on fixtures/conformance/error-duplicate-name-in-system/input -> ['ERR_DUPLICATE_NAME'] (negative)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Source-predicate sweep: every "has any source" site, classified (maintainer ruling: an object whose only sources are non-rdb is treated like one with no relational source)
Source sweep: "any source" vs "relational source" questions
Every non-test site in the five ports that asks whether an object has a source, or whether all its sources are of one kind, is listed below. Fix labels: A = 9dc01ce (writability, one-primary rule, @ROLE rdb-only), B = 4bc145d (non-rdb counted as sourceless), C = 4ccffec (payload shapes vs source.rdb). "pre-existing" means the site was already rdb-only before this PR (git blame). The
MetaSourcepredicates (isWritable/isReadOnlyand equivalents) are now rdb-only in every port, so every caller of them inherits rdb-only behavior. They are listed once per port under "predicates".Line numbers are for the PR head and may shift by a few lines.
TypeScript (server/typescript/packages)
isReadOnly) | rdb-only via predicate | unchanged: predicate now rdb-onlyC# (server/csharp)
Java / Kotlin (server/java)
Python (server/python/src/metaobjects)
Rust (server/rust)
kindattr is read-only | any-source | unchanged: see remaining-defect candidatesRemaining-defect candidates (relational question, still counts any source)
type_name == T_SOURCE && READ_ONLY_KINDS.contains(attr "kind" or "table"), with no rdb check. The other four ports ask the same question through an rdb-only predicate (TS validation-passes.ts:2092, C# ValidationPasses.cs:2243, Java ValidationPhase.java:6245, Python validation_passes.py:4321). It is only latent:source.basecarries no attrs, so asource.documentorsource.searchcannot legally declare@kind: viewand Rust would read the defaulttable, which is not read-only. If a document or search provider ever registers akindattr, Rust would skip the check for such an entity while the other ports would not. Suggested hardening: usecrate::naming::source_is_read_only(tree, c).@parameterRef, a callable@kindor@unmanagedoff every source. Those are rdb-only attrs, so a non-rdb source never matches.